Full source code website bán hàng thương mại điện tử gần giống shopee
468.831 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%">Tài liệu đính kèm : <a href="./?act=tailieu_m&page=<? echo $_REQUEST['page']; ?>"><font class="V10pt" color="#ffffff">Nhập Mới</font></a>
4 </td>
5 </tr>
6 </table>
7 <?
8 switch ($_GET['action'])
9 {
10 case 'del' :
11 $id = $_GET['id'];
12 $sql="select * from tailieu where doc_files_id=$id limit 1";
13 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
14 if ($pro)
15 {
16 $sql = "delete from tailieu where doc_files_id='".$id."'";
17 $result = mysql_query($sql,$con);
18 if ($result)
19 {
20 if (file_exists($pro['doc_files_file'])) unlink($pro['doc_files_file']);
21 echo "<p align=center class='err'>Đã xóa thành công</p>";
22 }
23 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
24 }
25 break;
26 }
27 ?>
28
29 <?
30 if (isset($_POST['ButDel'])) {
31 $cnt=0;
32 foreach ($_POST['chk'] as $id)
33 {
34 $sql="select * from tailieu where doc_files_id=$id limit 1";
35 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
36 if ($pro)
37 {
38 @$result = mysql_query("delete from tailieu where doc_files_id='".$id."'",$con);
39 if ($result) {
40 $cnt++;
41 if (file_exists($pro['doc_files_file'])) unlink($pro['doc_files_file']);
42 }
43 }
44 }
45 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
46 }
47 ?>
48
49 <?
50 $page = $_GET["page"];
51 //$MAXPAGE=10;
52 $p=0;
53 if ($page!='') $p=$page;
54 $where="1=1";
55 if ($_REQUEST['cat']!='') $where="doc_files_categoriesid=".$_REQUEST['cat'];
56
57 ?>
58 <form method="POST" name="frmList" action="index.php">
59 <input type="hidden" name="act" value="tailieu">
60 <input type=hidden name="page" value="<? echo $page; ?>">
61 <?
62 function taotrang($total,$link,$nitem,$itemcurrent,$step=10)
63 { global $con;
64 $ret="";
65
66 $param="";
67 $pages=count_page($total,$nitem);
68 if ($itemcurrent>0) $ret.='<a title="Đầu tiên" href="'.$link.'0" class="lslink">[<]</a> ';
69 if ($itemcurrent>1) $ret.='<a title="Về trước" href="'.$link.($itemcurrent-1).'" class="lslink">[<<]</a> ';
70 $from=($itemcurrent-$step>0?$itemcurrent-$step:0);
71 $to=($itemcurrent+$step<$pages?$itemcurrent+$step:$pages);
72 for ($i=$from;$i<$to;$i++)
73 {
74 if ($i!=$itemcurrent) $ret.='<a href="'.$link.$i.'" class="lslink">'.($i+1).'</a> ';
75 else $ret.='<b>'.($i+1).'</b> ';
76 }
77 if ($itemcurrent<$pages-2) $ret.='<a title="Tiếp theo" href="'.$link.($itemcurrent+1).'">[>>]</a> ';
78 if ($itemcurrent<$pages-1) $ret.='<a title="Cuối cùng" href="'.$link.($pages-1).'">[>]</a>';
79 return $ret;
80 }
81 $pageindex=taotrang(CountRecord("tailieu",$where),"./?act=tailieu&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
82 ?>
83
84 <table cellspacing="0" cellpadding="0" width="100%">
85 <? if ($_REQUEST['code']==1) echo '<tr><td align="center" class="err" colspan="3">Đã cập nhật thành công</td></tr>'; ?>
86 <tr>
87 <td class="smallfont" >Trang : <? echo $pageindex; ?></td>
88 <td height="30" align="right" class="smallfont">
89 <select size="1" name="ddCat" class="smallfont">
90 <?
91 $ms=GetListProduct();
92 echo '<option value="">[Tất cả]</option>';
93 foreach ($ms as $m)
94 if ($m[0]!=$_REQUEST['cat'])
95 echo '<option value="'.$m[0].'">'.$m[1].'</option>';
96 else
97 echo '<option selected value="'.$m[0].'">'.$m[1].'</option>';
98 ?>
99 </select>
100 <input type="button" value="Chuyển" class="button" onclick="window.location='./?act=tailieu&cat='+ddCat.value">
101 </td>
102 </tr>
103 </table>
104
105 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
106 <tr>
107 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
108 <td colspan="2" nowrap class="title"> </td>
109 <td align="center" nowrap class="title"><b>Mã</b></td>
110 <td align="center" nowrap class="title"><b>Tên</b></td>
111 <td align="center" nowrap class="title"><b>File</b></td>
112 <td align="center" nowrap class="title"><b>Không hiện</b></td>
113 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
114 <td align="center" nowrap class="title"><b>Ngày</b></td>
115 </tr>
116
117 <?php
118 $sql="select * from tailieu where $where order by doc_files_id limit ".($p*$MAXPAGE).",".$MAXPAGE;
119 $result=mysql_query($sql,$con);
120 $i=0;
121 while(($row=mysql_fetch_array($result)))
122 {
123 $i++;
124 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
125 ?>
126
127 <tr>
128 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
129 <input type="checkbox" name="chk[]" value="<? echo $row['doc_files_id']; ?>"></td>
130 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
131 <a href="./?act=tailieu_m&id=<? echo $row['doc_files_id']; ?>&page=<? echo $_REQUEST['page'];?>">
132 Sửa</a></td>
133 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
134 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=tailieu&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['doc_files_id']; ?>">xoá</a></td>
135 <td bgcolor="<? echo $color; ?>" align="left" align="left" class="smallfont"><? echo $row['doc_files_id']; ?> </td>
136 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_name']; ?> </td>
137 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_file']; ?> </td>
138 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_status']; ?> </td>
139 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_categoriesid']; ?> </td>
140 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_dateadded']; ?> </td>
141 </tr>
142 <?
143 }
144 ?>
145 </table>
146 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
147 </form>
148 <script language="JavaScript">
149 function chkallClick(o) {
150 var form = document.frmList;
151 for (var i = 0; i < form.elements.length; i++) {
152 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
153 form.elements[i].checked = document.frmList.chkall.checked;
154 }
155 }
156 }
157 </script>
2 <tr align=center>
3 <td class="title" width="100%">Tài liệu đính kèm : <a href="./?act=tailieu_m&page=<? echo $_REQUEST['page']; ?>"><font class="V10pt" color="#ffffff">Nhập Mới</font></a>
4 </td>
5 </tr>
6 </table>
7 <?
8 switch ($_GET['action'])
9 {
10 case 'del' :
11 $id = $_GET['id'];
12 $sql="select * from tailieu where doc_files_id=$id limit 1";
13 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
14 if ($pro)
15 {
16 $sql = "delete from tailieu where doc_files_id='".$id."'";
17 $result = mysql_query($sql,$con);
18 if ($result)
19 {
20 if (file_exists($pro['doc_files_file'])) unlink($pro['doc_files_file']);
21 echo "<p align=center class='err'>Đã xóa thành công</p>";
22 }
23 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
24 }
25 break;
26 }
27 ?>
28
29 <?
30 if (isset($_POST['ButDel'])) {
31 $cnt=0;
32 foreach ($_POST['chk'] as $id)
33 {
34 $sql="select * from tailieu where doc_files_id=$id limit 1";
35 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
36 if ($pro)
37 {
38 @$result = mysql_query("delete from tailieu where doc_files_id='".$id."'",$con);
39 if ($result) {
40 $cnt++;
41 if (file_exists($pro['doc_files_file'])) unlink($pro['doc_files_file']);
42 }
43 }
44 }
45 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
46 }
47 ?>
48
49 <?
50 $page = $_GET["page"];
51 //$MAXPAGE=10;
52 $p=0;
53 if ($page!='') $p=$page;
54 $where="1=1";
55 if ($_REQUEST['cat']!='') $where="doc_files_categoriesid=".$_REQUEST['cat'];
56
57 ?>
58 <form method="POST" name="frmList" action="index.php">
59 <input type="hidden" name="act" value="tailieu">
60 <input type=hidden name="page" value="<? echo $page; ?>">
61 <?
62 function taotrang($total,$link,$nitem,$itemcurrent,$step=10)
63 { global $con;
64 $ret="";
65
66 $param="";
67 $pages=count_page($total,$nitem);
68 if ($itemcurrent>0) $ret.='<a title="Đầu tiên" href="'.$link.'0" class="lslink">[<]</a> ';
69 if ($itemcurrent>1) $ret.='<a title="Về trước" href="'.$link.($itemcurrent-1).'" class="lslink">[<<]</a> ';
70 $from=($itemcurrent-$step>0?$itemcurrent-$step:0);
71 $to=($itemcurrent+$step<$pages?$itemcurrent+$step:$pages);
72 for ($i=$from;$i<$to;$i++)
73 {
74 if ($i!=$itemcurrent) $ret.='<a href="'.$link.$i.'" class="lslink">'.($i+1).'</a> ';
75 else $ret.='<b>'.($i+1).'</b> ';
76 }
77 if ($itemcurrent<$pages-2) $ret.='<a title="Tiếp theo" href="'.$link.($itemcurrent+1).'">[>>]</a> ';
78 if ($itemcurrent<$pages-1) $ret.='<a title="Cuối cùng" href="'.$link.($pages-1).'">[>]</a>';
79 return $ret;
80 }
81 $pageindex=taotrang(CountRecord("tailieu",$where),"./?act=tailieu&cat=".$_REQUEST['cat']."&page=",$MAXPAGE,$page);
82 ?>
83
84 <table cellspacing="0" cellpadding="0" width="100%">
85 <? if ($_REQUEST['code']==1) echo '<tr><td align="center" class="err" colspan="3">Đã cập nhật thành công</td></tr>'; ?>
86 <tr>
87 <td class="smallfont" >Trang : <? echo $pageindex; ?></td>
88 <td height="30" align="right" class="smallfont">
89 <select size="1" name="ddCat" class="smallfont">
90 <?
91 $ms=GetListProduct();
92 echo '<option value="">[Tất cả]</option>';
93 foreach ($ms as $m)
94 if ($m[0]!=$_REQUEST['cat'])
95 echo '<option value="'.$m[0].'">'.$m[1].'</option>';
96 else
97 echo '<option selected value="'.$m[0].'">'.$m[1].'</option>';
98 ?>
99 </select>
100 <input type="button" value="Chuyển" class="button" onclick="window.location='./?act=tailieu&cat='+ddCat.value">
101 </td>
102 </tr>
103 </table>
104
105 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
106 <tr>
107 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
108 <td colspan="2" nowrap class="title"> </td>
109 <td align="center" nowrap class="title"><b>Mã</b></td>
110 <td align="center" nowrap class="title"><b>Tên</b></td>
111 <td align="center" nowrap class="title"><b>File</b></td>
112 <td align="center" nowrap class="title"><b>Không hiện</b></td>
113 <td align="center" nowrap class="title"><b>Thuộc danh mục</b></td>
114 <td align="center" nowrap class="title"><b>Ngày</b></td>
115 </tr>
116
117 <?php
118 $sql="select * from tailieu where $where order by doc_files_id limit ".($p*$MAXPAGE).",".$MAXPAGE;
119 $result=mysql_query($sql,$con);
120 $i=0;
121 while(($row=mysql_fetch_array($result)))
122 {
123 $i++;
124 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
125 ?>
126
127 <tr>
128 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
129 <input type="checkbox" name="chk[]" value="<? echo $row['doc_files_id']; ?>"></td>
130 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
131 <a href="./?act=tailieu_m&id=<? echo $row['doc_files_id']; ?>&page=<? echo $_REQUEST['page'];?>">
132 Sửa</a></td>
133 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
134 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=tailieu&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['doc_files_id']; ?>">xoá</a></td>
135 <td bgcolor="<? echo $color; ?>" align="left" align="left" class="smallfont"><? echo $row['doc_files_id']; ?> </td>
136 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_name']; ?> </td>
137 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_file']; ?> </td>
138 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_status']; ?> </td>
139 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_categoriesid']; ?> </td>
140 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['doc_files_dateadded']; ?> </td>
141 </tr>
142 <?
143 }
144 ?>
145 </table>
146 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
147 </form>
148 <script language="JavaScript">
149 function chkallClick(o) {
150 var form = document.frmList;
151 for (var i = 0; i < form.elements.length; i++) {
152 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
153 form.elements[i].checked = document.frmList.chkall.checked;
154 }
155 }
156 }
157 </script>